package com.sangeng.controller;

import com.sangeng.domain.ResponseResult;
import com.sangeng.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件上传接口，前端将文件或者图片上传到服务器，服务器通过七牛云的api将文件保存在
 * 七牛云的存储空间中，并且返回文件的外链
 */
@RestController
public class UploadController {
    @Autowired
    private UploadService uploadService;

    /**
     * 文件上传
     * @param img
     * @return
     */
    @PostMapping("/upload")
    public ResponseResult uploadImg(MultipartFile img){

        return uploadService.uploadImg(img);
    }
}

